﻿using PhotoKiosk.Model;
using PhotoKiosk.ViewModel.Helpers;
using System.Globalization;
using System.Windows.Input;

namespace PhotoKiosk.ViewModel.UserControls
{
    public class PaperSizeViewModel : ViewModelBase
    {
        private PaperSize m_paperSize;

        public PaperSizeViewModel(PaperSize i_paperSize)
        {
            m_paperSize = i_paperSize;
        }

        public string SizeText
        {
            get
            {
                return m_paperSize.ToString();
            }
        }

        public string PriceText
        {
            get
            {
                return RegionInfo.CurrentRegion.CurrencySymbol + " " + m_paperSize.Price.ToString();
            }
        }

        #region Select Command
        private DelegateCommand m_selectCommand;
        public ICommand SelectCommand
        {
            get
            {
                if (m_selectCommand == null)
                {
                    m_selectCommand = new DelegateCommand(param => this.selectCommandExecute(), param => this.selectCommandCanExecute());
                }
                return m_selectCommand;
            }
        }

        private bool selectCommandCanExecute()
        {
            return true;
        }

        private void selectCommandExecute()
        {
            if (OnClick != null)
            {
                OnClick(m_paperSize);
            }
            IsSelected = true;
        }

        private bool m_isSelected = false;
        public bool IsSelected
        {
            get
            {
                return m_isSelected;
            }
            set
            {
                m_isSelected = value;
                OnPropertyChanged("IsSelected");
            }
        }
        #endregion

        #region OnClick Event
        public event ClickHandler OnClick;
        public delegate void ClickHandler(PaperSize i_paperSize);
        #endregion
    }
}
